﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StressTesterCommon;
using System.ComponentModel;

namespace StressServer.ViewModel
{
    public class QueryViewModel:INotifyPropertyChanged
    {
        private Query _Query;

        public Query Query
        {
            get { return _Query; }
            set { _Query = value; }
        }

        public QueryViewModel(Query Query)
        {
            _Query = Query;
        }

        public string Name
        {
            get { return _Query.Name; }
            set { if (value != _Query.Name) { _Query.Name = value; OnPropertyChanged("Name"); } }
        }

        public string Text
        {
            get { return _Query.RawText; }
            set { if (value != _Query.RawText) { _Query.RawText = value; OnPropertyChanged("RawText"); } }
        }

        #region NotifyPropertyChanged
        public event PropertyChangedEventHandler PropertyChanged;
        private void OnPropertyChanged(string info)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(info));
            }
        }
        #endregion
    }
}
